<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>首页</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta http-equiv="Access-Control-Allow-Origin" content="*">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="icon" href="/static/images/favicon.ico">
		<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
		<style id="layuimini-bg-color">
			div img {
				width: 100%;
				height: 100%;
				transition: all 0.5s;
			}

			div img:hover {
				transform: scale(1.1);
			}
		</style>
	</head>
	<body>
		<div class="layui-fluid"
			style="background-color: cyan;height: 60px;background-image: url(/static/images/loginbg.png);">
			<div class="layui-row">
				<div class="layui-col-sm6">
					<div class="grid-demo">
						<ul id="menu" class="layui-nav" style="background-color:transparent;">
							<li class="layui-nav-item" value="0"><a href="/">首页</a></li>
						</ul>
					</div>
				</div>
				<div class="layui-col-sm6">
					<div class="grid-demo">
						<ul id="not_login" class="layui-nav"
							style="background-color:transparent;float: right;display:block">
							<li class="layui-nav-item">
								<a href="">vip</a>
							</li>
							<li class="layui-nav-item">
								<a href="/login.html">登录</a>
							</li>
							<li class="layui-nav-item">
								<span>|</span>
							</li>
							<li class="layui-nav-item">
								<a href="">注册</a>
							</li>
						</ul>
						<ul id="login" class="layui-nav" style="background-color:transparent;float: right;display:none">
							<li class="layui-nav-item">
								<a id="vip" href="/web_profile.html?value=2"></a>
							</li>
							<li class="layui-nav-item">
								<a id="user_name" href=""></a>
								<dl class="layui-nav-child">
									<dd>
										<a href="/web_profile.html?value=1"
											layuimini-content-href="page/user-setting.html" data-title="基本资料"
											data-icon="fa fa-gears">基本资料<span class="layui-badge-dot"></span></a>
									</dd>
									<dd>
										<a href="/web_profile.html?value=4"
											layuimini-content-href="page/user-password.html" data-title="修改密码"
											data-icon="fa fa-gears">修改密码</a>
									</dd>
									<dd>
										<hr>
									</dd>
									<dd>
										<a href="javascript:;" class="login_out">退出登录</a>
									</dd>
								</dl>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<br />

		<div class="layui-container layui-row">
			<div class="layui-col-md3">
				<div class="layui-panel site-menu" style="width: auto;">
					<ul class="layui-menu layui-menu-lg site-docs-menu">
						<li class="layui-menu-item-group" lay-options="{type: 'group', isAllowSpread: true}">
							<span>基础资料</span>

							<hr>
							<ul>
								<li>
									<div class="layui-menu-body-title">
										<a href="/web_profile.html?value=1">
											<span>我的资料</span>
										</a>
									</div>
								</li>
								<li>
									<div class="layui-menu-body-title">
										<a href="/web_profile.html?value=2">
											<span>升级VIP</span>
										</a>
									</div>
								</li>
								<li>
									<div class="layui-menu-body-title">
										<a href="/web_profile.html?value=3">
											<span>购买记录</span>
										</a>
									</div>
								</li>
								<li>
									<div class="layui-menu-body-title">
										<a href="/web_profile.html?value=4">
											<span>修改密码</span>
										</a>
									</div>
								</li>
							</ul>
						</li>
					</ul>
				</div>
			</div>


			<div class="layui-col-md8 site-content">
				<div class="layui-panel site-menu" style="width: auto;display: none" id="myinformation">
					<blockquote class="layui-elem-quote">
						<h3 class="site-h1">我的资料</h3>
					</blockquote>
					<div class="site-title">
						<div class="layui-form-item layui-col-lg-offset1">
							<div class="layui-upload">
								<div class="layui-upload-list" style="height: 30%;width: 30%;">
									<img class="layui-upload-img" id="demo1" src="//t.cn/RCzsdCq">
								</div>
								<button type="button" class="layui-btn" id="edit-avatar">修改头像</button>
							</div>
						</div>
						<hr />
						<form class="layui-form">
							<div class="layui-form-item">
								<label class="layui-form-label">用户名</label>
								<div class="layui-input-block">
									<input type="text" name="username" lay-verify="title" autocomplete="off"
										placeholder="请输入用户名" class="layui-input" id="username">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">邮箱</label>
								<div class="layui-input-block">
									<input type="text" name="mail" lay-verify="title" autocomplete="off"
										placeholder="请输入邮箱" class="layui-input" id="mail">
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block">
									<button type="button" class="layui-btn" id="save-profile">保存</button>
								</div>
							</div>
						</form>
					</div>
				</div>


				<div class="layui-panel site-menu" style="width: auto;display: none;" id="upvip">
					<blockquote class="layui-elem-quote">
						<h3 class="site-h1">升级VIP</h3>
						<span style="color: red;">注意：课程和会员是（虚拟产品），订阅成功后不支持退款，如有疑问先咨询后购买！</span>
					</blockquote>
					<div class="site-title">
						<div class="layui-bg-gray" style="padding: 30px;">
							<div class="layui-row layui-col-space10">
								<!--一年vip-->
								<div class="layui-col-md12" id="oneyear">
									<div class="layui-panel">
										<div style="padding: 15px 30px;border:;background-color:;" id="div-oneyear">
											<div class="layui-row">
												<div class="layui-col-md10"><span style="font-size: 25px;">一年VIP</span>
												</div>
												<div class="layui-col-md2"><span
														style="color:#ff6600;font-size: 25px;float:right">￥258.00</span>
												</div>
												<div class="layui-col-md10"><span>自助开通|全站免费下载|自学成才</span></div>
												<div class="layui-col-md2"><span
														style="text-decoration:line-through;float:right">￥298.00</span>
												</div>
											</div>
										</div>
									</div>
								</div>
								<!--终身vip-->
								<div class="layui-col-md12" id="lifelong">
									<div class="layui-panel">
										<div style="padding: 15px 30px;border:;background-color: ;" id="div-lifelong">
											<div class="layui-row">
												<div class="layui-col-md10"><span style="font-size: 25px;">终身VIP</span>
												</div>
												<div class="layui-col-md2"><span
														style="color:#ff6600;font-size: 25px;float:right">￥468.00</span>
												</div>
												<div class="layui-col-md10"><span>终身受益|每周20-30新课程|学无止境</span></div>
												<div class="layui-col-md2"><span
														style="text-decoration:line-through;float:right">￥528.00</span>
												</div>
											</div>
										</div>
									</div>
								</div>

							</div>
						</div>
					</div>
					<!-- 支付按钮 -->
					<div class="layui-row " style="background-color: rgba(255, 102, 0, 0.05);padding: 20px;">
						<div class="layui-col-md9">
							<div style="float:right" id="zfb">
								<img src="/static/images/支付宝.png"
									style="padding: 2px;border:2px solid green;background-color: white;height: 38px;width: 110px;" />
							</div>
						</div>
						<div class="layui-col-md2 layui-col-md-offset1">
							<button type="button" class="layui-btn layui-btn-danger" style="float: left;" id="paybutton"
								data-method="notice">立即升级</button>
						</div>
					</div>
				</div>


				<div class="layui-panel site-menu" style="width: auto;display: ;" id="purchaserecord">
					<blockquote class="layui-elem-quote">
						<h3 class="site-h1">购买记录</h3>
					</blockquote>

					<div class="layui-row layui-col-space15">
						<div class="layui-col-md12" style="padding: 20px;">
							<ul class="flow-default" style="height: 100%;width: 100%;" id="OrderList">
								<!--流加载-->
								<!-- <li style="padding: 8px;"><div class="layui-panel"><div style="padding: 10px 10px;"><div class="layui-row layui-col-space15">
								<div class="layui-col-md2"><img src='//t.cn/RCzsdCq'></div>
								<div class="layui-col-md10"><div class="layui-row"><div class="layui-col-md12">
								<span style="font-size: large;">标题标题</span>
								<span style="font-size: large;float:right;text-decoration:line-through">155.00</span></div>
								<div class="layui-col-md12"><span style="font-size: large;">2022-12-15</span>
								<span style="font-size: large;float:right;color: red">实际支付：0.00</span></div>
								<div class="layui-col-md12"></br></br><span style="font-size: large;">已完成</span>
								<button id="GetResourcesButton" type="button"class="layui-btn layui-btn-primary layui-border-green" style="float:right;">获取资源</button></div></div></div></div></div></div></li> -->
							</ul>
						</div>
					</div>
				</div>


				<div class="layui-panel site-menu" style="width: auto;display: none;" id="ChangePassword">
					<blockquote class="layui-elem-quote">
						<h3 class="site-h1">修改密码</h3>
					</blockquote>
					<div class="site-title">
						<form class="layui-form">
							<div class="layui-form-item">
								<label class="layui-form-label">密码</label>
								<div class="layui-input-inline">
									<input type="password" name="onepassword" required lay-verify="required"
										placeholder="请输入密码" autocomplete="off" class="layui-input" id="onepassword">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">确认密码</label>
								<div class="layui-input-inline">
									<input type="password" name="twopassword" required lay-verify="required"
										placeholder="请输入密码" autocomplete="off" class="layui-input" id="twopassword">
								</div>
							</div>

							<div class="layui-form-item">
								<div class="layui-input-block">
									<button type="button" class="layui-btn" id="save-password">保存</button>
								</div>
							</div>
						</form>
					</div>
				</div>

			</div>

		</div>

		</div>



		<script src="/static/lib/layui-v2.6.3/layui.js"></script>

		<script>
			function getCookie(name) {
				var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
				return r ? r[1] : undefined;
			}

			function getlocalURL() {
				var localURL = window.location.href;
				var url = localURL.split("&")
				return url[0]
			}

			function getQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if (r != null) {
					return decodeURI(r[2]);
				}
				return '';
			}

			var order_course_id;

			function GetResourcesButton(obj) {
				order_course_id = obj.id
				// console.log(obj.id)
				let sendEmailData = {
					"course_id": order_course_id
				}
				layui.use(['form', 'layedit', 'laydate', 'flow', 'element', 'layer'], function() {
					var form = layui.form,
						layer = layui.layer,
						layedit = layui.layedit,
						laydate = layui.laydate,
						flow = layui.flow,
						element = layui.element,
						upload = layui.upload,
						table = layui.table,
						$ = layui.jquery;
					$.ajax({
						type: "post", //get或者post
						contentType: 'application/json',
						headers: {
							'X-CSRFToken': getCookie('csrf_token')
						},
						url: '/api/v1.0/sendEmail',
						data: JSON.stringify(sendEmailData), //参数 接口传参 json对象
						success: function(res) {
							if (res.code == "0") {
								layer.msg('发送成功，请注意查收邮件');
							} else {
								layer.msg('发送失败')
							}
							// alert("成功获取")
						}
					});
				})
			}

			var val = getQueryString("value")

			layui.use(['form', 'layedit', 'laydate', 'flow', 'element', 'layer'], function() {
				var form = layui.form,
					layer = layui.layer,
					layedit = layui.layedit,
					laydate = layui.laydate,
					flow = layui.flow,
					element = layui.element,
					upload = layui.upload,
					table = layui.table,
					$ = layui.jquery;


				var avatar_img = "";
				var is_vip = "";
				//检查登录状态
				$.ajax({
					type: "post", //get或者post
					headers: {
						'X-CSRFToken': getCookie('csrf_token')
					},
					url: '/api/v1.0/check_login',
					data: {}, //参数 接口传参 json对象
					success: function(res) {
						// console.log(res);
						if ("0" == res.code) {
							if (res.data.user_id == "1") {
								location.href = "/"
							} else {
								// location.href = "/web_index.html"
								avatar_img = res["data"]["avatar"]
								is_vip = res["data"]["is_vip"]
								console.log(res["data"]["avatar"]);
								console.log(res["data"]["is_vip"]);
								var not_login = document.getElementById('not_login');
								not_login.style.display = 'none'
								var login = document.getElementById('login');
								login.style.display = 'block'
								var a = document.getElementById('user_name'); //获取a元素对象
								if (avatar_img == "") {
									a.innerHTML = '<img src="' + '//t.cn/RCzsdCq' +
										'" class="layui-nav-img">' +
										res.data.user_name;
								} else {
									a.innerHTML = '<img src="' + avatar_img +
										'" class="layui-nav-img">' +
										res.data.user_name;
								}
								var avip = document.getElementById('vip'); //获取a元素对象
								if (is_vip == 1) {
									avip.innerHTML = '<img src="/static/images/vipicon-5.png"/>';

								} else {
									avip.innerHTML = 'vip';
								}
							}

						} else {
							$(".not_login").show();
						}
					}
				});


				if (val == "1") {
					document.getElementById("myinformation").style.display = "";
					document.getElementById("upvip").style.display = "none";
					document.getElementById("purchaserecord").style.display = "none";
					document.getElementById("ChangePassword").style.display = "none";
				} else if (val == "2") {
					document.getElementById("myinformation").style.display = "none";
					document.getElementById("upvip").style.display = "";
					document.getElementById("purchaserecord").style.display = "none";
					document.getElementById("ChangePassword").style.display = "none";
				} else if (val == "3") {
					document.getElementById("myinformation").style.display = "none";
					document.getElementById("upvip").style.display = "none";
					document.getElementById("purchaserecord").style.display = "";
					document.getElementById("ChangePassword").style.display = "none";
				} else if (val == "4") {
					document.getElementById("myinformation").style.display = "none";
					document.getElementById("upvip").style.display = "none";
					document.getElementById("purchaserecord").style.display = "none";
					document.getElementById("ChangePassword").style.display = "";
				}




				flow.load({
					elem: '#OrderList', //流加载容器
					// isAuto: false,
					// isLazyimg: true,
					done: function(page, next) { //执行下一页的回调
						$.ajax({
							type: "post", //get或者post
							contentType: 'application/json',
							headers: {
								'X-CSRFToken': getCookie('csrf_token')
							},
							url: '/api/v1.0/orders/list',
							// data: {}, //参数 接口传参 json对象
							success: function(res) {
								var lis = [];
								var order_list = [];
								order_list = res.data
								console.log(order_list)
								//假设你的列表返回在data集合中
								layui.each(order_list, function(index, item) {
									console.log(item["index_image_url"])
									console.log(item["title"])
									console.log(item["create_time"])
									console.log(item["order_price"])
									var status;
									if (is_vip == 1) {
										if (item["order_status"] == 2) {
											status = "已完成";
											lis.push(
												'<li style="padding: 8px;"><div class="layui-panel"><div style="padding: 10px 10px;"><div class="layui-row layui-col-space15">' +
												'<div class="layui-col-md2"><img src=' +
												item["index_image_url"] + '></div>' +
												'<div class="layui-col-md10"><div class="layui-row"><div class="layui-col-md12">' +
												'<span style="font-size: large;">' +
												item["title"] + '</span>' +
												'<span style="font-size: large;float:right;text-decoration:line-through">' + '<i class="layui-icon layui-icon-diamond"></i>'+
												item["order_price"] +
												'</span></div>' +
												'<div class="layui-col-md12"><span style="font-size: large;">2022-12-15</span>' +
												'<span style="font-size: large;float:right;color: red">实际支付：0.00</span></div>' +
												'<div class="layui-col-md12"></br></br><span style="font-size: large;">' +
												status + '</span>' +
												'<button id="GetResourcesButton" id="' +
												item["course_id"] +
												'" type="button" class="layui-btn layui-btn-primary layui-border-green" style="float:right;">获取资源</button></div></div></div></div></div></div></li>'
											)
										} else {
											status = "已取消";
											lis.push(
												'<li style="padding: 8px;"><div class="layui-panel"><div style="padding: 10px 10px;"><div class="layui-row layui-col-space15">' +
												'<div class="layui-col-md2"><img src=' +
												item["index_image_url"] + '></div>' +
												'<div class="layui-col-md10"><div class="layui-row"><div class="layui-col-md12">' +
												'<span style="font-size: large;">' +
												item["title"] + '</span>' +
												'<span style="font-size: large;float:right;text-decoration:line-through">' +
												item["order_price"] +
												'</span></div>' +
												'<div class="layui-col-md12"><span style="font-size: large;">2022-12-15</span>' +
												'</div>' +
												'<div class="layui-col-md12"></br></br><span style="font-size: large;">' +
												status + '</span>' +
												'</div></div></div></div></div></div></li>'
											)
										}
									} else {
										if (item["order_status"] == 2) {
											status = "已完成";
											lis.push(
												'<li style="padding: 8px;"><div class="layui-panel"><div style="padding: 10px 10px;"><div class="layui-row layui-col-space15">' +
												'<div class="layui-col-md2"><img src=' +
												item["index_image_url"] + '></div>' +
												'<div class="layui-col-md10"><div class="layui-row"><div class="layui-col-md12">' +
												'<span style="font-size: large;">' +
												item["title"] + '</span>' +
												'<span style="font-size: large;float:right;">' + '<i class="layui-icon layui-icon-diamond"></i>'+
												item["order_price"] +
												'</span></div>' +
												'<div class="layui-col-md12"><span style="font-size: large;">2022-12-15</span>' +
												'<span style="font-size: large;float:right;color: red">实际支付：' +'<i class="layui-icon layui-icon-diamond"></i>'+
												item["order_price"] + 
												'</span></div>' +
												'<div class="layui-col-md12"></br></br><span style="font-size: large;">' +
												status + '</span>' +
												'<button onclick="GetResourcesButton(this)" id="' +
												item["course_id"] +
												'" type="button"class="layui-btn layui-btn-primary layui-border-green" style="float:right;">获取资源</button></div></div></div></div></div></div></li>'
											)
										} else {
											status = "已取消";
											lis.push(
												'<li style="padding: 8px;"><div class="layui-panel"><div style="padding: 10px 10px;"><div class="layui-row layui-col-space15">' +
												'<div class="layui-col-md2"><img src=' +
												item["index_image_url"] + '></div>' +
												'<div class="layui-col-md10"><div class="layui-row"><div class="layui-col-md12">' +
												'<span style="font-size: large;">' +
												item["title"] + '</span>' +
												'<span style="font-size: large;float:right;">' + '<i class="layui-icon layui-icon-diamond"></i>'+
												item["order_price"] +
												'</span></div>' +
												'<div class="layui-col-md12"><span style="font-size: large;">2022-12-15</span>' +
												'</div>' +
												'<div class="layui-col-md12"></br></br><span style="font-size: large;">' +
												status + '</span>' +
												'</div></div></div></div></div></div></li>'
											)
										}
									}
								});


								//执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
								//count为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
								next(lis.join(''), page < order_list.count);

							}
						});
					}
				})






				//常规使用 - 普通图片上传
				var uploadInst = upload.render({
					elem: '#edit-avatar',
					url: '/api/v1.0/users/avatar' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
						,
					headers: {
						// 'Content-Type': 'application/json;charset=UTF-8',
						'X-CSRFToken': getCookie('csrf_token')
					},
					before: function(obj) {
						//预读本地文件示例，不支持ie8
						obj.preview(function(index, file, result) {
							$('#demo1').attr('src', result); //图片链接（base64）
						});
					},
					done: function(res) {
						avatar_url = res['data']['avatar_url']
						//如果上传失败
						if (res.code > 0) {
							return layer.msg('上传失败');
						}
					},
					error: function() {
						//演示失败状态，并实现重传
						var demoText = $('#demoText');
						demoText.html(
							'<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>'
						);
						demoText.find('.demo-reload').on('click', function() {
							uploadInst.upload();
						});
					}

				});



				function addli_dl(key, value) {
					var li = document.createElement("li")
					li.className = "layui-nav-item"
					li.value = key
					li.innerHTML = '<a href="/web_courselist.html?contents=' + key + '">' + value +
						'</a>'
					document.getElementById("menu").appendChild(li)
					return li
				}


				//获取所有menu菜单
				$.ajax({
					type: "post", //get或者post
					contentType: 'application/json',
					headers: {
						'X-CSRFToken': getCookie('csrf_token')
					},
					url: '/api/v1.0/get_contents_all_list',
					data: {}, //参数 接口传参 json对象
					success: function(res) {
						$("#menu").find('span.layui-nav-bar').remove();
						var li;
						var dl = document.createElement("dl");
						dl.className = "layui-nav-child";

						$.each(res.data, function(index, value) {
							if (value.contents_level == "0") {
								li = addli_dl(value.contents_id, value
									.contents_name)
							}
							if (value.contents_level != "0") {

								$.each(res.data, function(index, valueparent) {
									// console.log(valueparent.contents_level)
									if (value.contents_level ==
										valueparent
										.contents_id) {
										var dd = document.createElement(
											"dd")
										dd.value = valueparent
											.contents_id
										dd.innerHTML =
											'<a href="/web_courselist.html?contents=' +
											value
											.contents_id + '">' + value
											.contents_name +
											'</a>'
										dl.appendChild(dd)
									}

									li.appendChild(dl)

								})
							}
						});
						element.render('ul');
						element.render('dl');

					}
				});


				// 个人信息修改
				$('#save-profile').on("click", function() {
					var input_username = document.getElementById("username")
					var input_mail = document.getElementById("mail")
					var username = input_username.value
					var mail = input_mail.value
					$.ajax({
						type: "post", //get或者post
						headers: {
							'X-CSRFToken': getCookie('csrf_token')

						},
						contentType: "application/json",
						url: '/api/v1.0/saveProfile',
						data: JSON.stringify({
							'avatar_url': avatar_url,
							'username': username,
							'mail': mail,
						}), //参数 接口传参 json对象
						success: function(res) {
							// layer.msg('保存成功')
							if (res.code == "0") {
								layer.msg('保存成功', function() {
									window.location.reload()
								});
							} else {
								layer.msg('保存失败')
							}
						}
					});
				});

				// 密码修改
				$('#save-password').on("click", function() {
					var input_onepassword = document.getElementById("onepassword")
					var input_twopassword = document.getElementById("twopassword")
					var onepassword = input_onepassword.value
					var twopassword = input_twopassword.value
					$.ajax({
						type: "post", //get或者post
						headers: {
							'X-CSRFToken': getCookie('csrf_token')
						},
						contentType: "application/json",
						url: '/api/v1.0/editPassword',
						data: JSON.stringify({
							'onepassword': onepassword,
							'twopassword': twopassword,
						}), //参数 接口传参 json对象
						success: function(res) {
							// layer.msg('保存成功')
							if (res.code == "0") {
								layer.msg('保存成功', function() {
									window.location.reload()
								});
							} else {
								layer.msg('保存失败')
							}
						}
					});
				});


				var paydata = ""
				// 一年vip
				$('#div-oneyear').on("click", function() {
					paydata = ""
					$("#div-oneyear").css("border", "2px solid red");
					$("#div-oneyear").css("background-color", "#fff6f1");
					$("#div-lifelong").css("border", "");
					$("#div-lifelong").css("background-color", "");
					paydata = {
						"total_amount": "258.00",
						"subject": "一年VIP"
					}
				});
				// 终生vip
				$('#div-lifelong').on("click", function() {
					paydata = ""
					$("#div-oneyear").css("border", "");
					$("#div-oneyear").css("background-color", "");
					$("#div-lifelong").css("border", "2px solid red");
					$("#div-lifelong").css("background-color", "#fff6f1");
					paydata = {
						"total_amount": "468.00",
						"subject": "终身VIP"
					}
				});


				layer.open({
					type: 1,
					title: false //不显示标题栏
						,
					closeBtn: false,
					area: '300px;',
					shade: 0.8,
					id: 'paybutton' //设定一个id，防止重复弹出
						,
					btn: ['取消付款', '已经付款'],
					btnAlign: 'c',
					moveType: 1 //拖拽模式，0或者1
						,
					content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">你知道吗？亲！<br>layer ≠ layui<br><br> layer 只是作为 layui 的一个弹层模块，由于其用户基数较大，所以常常会有人以为 layui 是 <del>layerui</del><br><br>layer 虽然已被 Layui 收编为内置的弹层模块，但仍然会作为一个独立组件全力维护、升级 ^_^</div>',
					success: function(layero) {
						var btn = layero.find('.layui-layer-btn');
						btn.find('.layui-layer-btn0').attr({
							href: '/',
							target: '_blank'
						});
					}
				});



				$('#paybutton').on("click", function() {
					// layer.msg('请选择需要开通的vip权限')
					if (paydata == "") {
						layer.msg('请选择需要开通的vip权限')
					} else {
						if (is_vip == "2") {
							$.ajax({
								type: "post", //get或者post
								headers: {
									'X-CSRFToken': getCookie('csrf_token')
								},
								contentType: "application/json",
								url: '/api/v1.0/vipalipayback',
								data: JSON.stringify(paydata), //参数接口传参 json对象
								success: function(res) {
									var gateway_url = res.data.gateway_url
									if (res.code == "0") {
										layer.msg('正在生成订单，等待支付', function() {
											// window.open(gateway_url)
											location.href = gateway_url
										})
									} else {
										layer.msg('对接失败')
									}
								}
							});
						} else {
							layer.msg('您已开通vip')
						}

					}
				});

				// var order_course_id = GetResourcesButton(Object)


				// $("." + order_course_id).on("click", function() {
				// 	// order_course_id = GetResourcesButton(obj)
				// 	console.log("点击");
				// 	// let sendEmailData = {
				// 	// 	"course_id": order_course_id
				// 	// }
				// 	// $.ajax({
				// 	// 	type: "post", //get或者post
				// 	// 	headers: {
				// 	// 		'X-CSRFToken': getCookie('csrf_token')
				// 	// 	},
				// 	// 	url: '/api/v1.0/sendEmail',
				// 	// 	data: JSON.stringify(sendEmailData), //参数 接口传参 json对象
				// 	// 	success: function(res) {
				// 	// 		if (res.code == "0") {
				// 	// 			layer.msg('发送成功，请注意查收邮件');
				// 	// 		} else {
				// 	// 			layer.msg('发送失败')
				// 	// 		}
				// 	// 	}
				// 	// });

				// })





				$('.login_out').on("click", function() {
					$.ajax({
						type: "post", //get或者post
						headers: {
							'X-CSRFToken': getCookie('csrf_token')
						},
						url: '/api/v1.0/logout',
						data: {}, //参数 接口传参 json对象
						success: function(res) {
							if (res.code == "0") {
								layer.msg('退出登录成功', function() {
									location.href = "/web_index.html"
									// window.location.reload()
								});
							} else {
								layer.msg('退出失败')
							}
						}
					});
				});

			})
		</script>

	</body>
</html>
